<template>
	<view class="goods-details">
		<u-navbar id="navbar" :border-bottom="false"
			:background="{ background: 'rgba(256,256,256, '+ navStyle.backgroundBg +')', }"
			:back-bg="'rgba(0,0,0,' + navStyle.backBg + ')'" :back-icon-color="navStyle.backColor" :immersive="true">
			<tabs sticky-bg-color="transparent" v-if="navStyle.backgroundBg > 0.1" :show-bar="true" :bar-width="60"
				:is-scroll="false" :current="active" bg-color="transparent"
				:style="{width: '100%', opacity: navStyle.backgroundBg}" @change="changeActive">
				<tab name="商品"></tab>
				<tab name="评价"></tab>
				<tab name="详情"></tab>
			</tabs>
		</u-navbar>

		<view class="contain" v-if="!isNull" id="goods" @touchstart="isTouchStart = true">

			<bubble-tips top="200rpx"></bubble-tips>

			<product-swiper :imgUrls="swiperList" :video="goodsDetail.video"></product-swiper>
			<!-- 秒杀 -->
			<view style="margin: 0 16rpx;">
				<view class="seckill flex row-between" v-if="goodsType == 1">
					<view class="price flex">
						<view class="flex white info">
							<view class="flex col-baseline m-l-20">
								<view class="m-r-10">秒杀价</view>
								<price-format :subscript-size="32" :first-size="46" :second-size="32"
									:price="checkedGoods.price || goodsDetail.price" :weight="500"></price-format>
								<view class="m-l-10">
									<price-format :subscript-size="30" :line-through="true" :first-size="30"
										:second-size="30"
										:price="checkedGoods.market_price || goodsDetail.market_price">
									</price-format>
								</view>
							</view>
						</view>
					</view>
					<view class="down flex-col col-center">
						<view class="xxs primary m-b-10">距活动结束仅剩</view>
						<u-count-down :timestamp="countTime" @end="getGoodsDetailFun" color="#fff"
							:bg-color="colorConfig.primary" :separator-color="colorConfig.primary" font-size="24"
							height="36" separator-size="26"></u-count-down>
					</view>
				</view>

				<!-- 拼团 -->
				<view class="group" v-show="goodsType == 2">
					<view class="row info" style="height: 100%">
						<view class="row-between ml20 white" style="flex: 1;">
							<view style="align-items: baseline;" class="row">
								<view class="mr10">拼团价</view>
								<price-format :subscript-size="32" :first-size="46" :second-size="32"
									:price="checkedGoods.team_price || team.team_min_price?team.team_min_price:''"
									:weight="500"></price-format>
							</view>
							<view class="mr20 row group-num">
								<view class="group-icon">
									<image src="/bundle/static/image/icon_group.png" class="icon-sm"></image>
								</view>
								<view class="xxs ml10 mr10">{{ team.people_num }}人团</view>
							</view>
						</view>
						<view class="down column-center">
							<view class="xxs primary mb10">距活动结束仅剩</view>
							<u-count-down :timestamp="countTime" color="#fff" bg-color="#FF2C3C"
								separator-color="#FF2C3C" font-size="24" height="36" separator-size="26"
								@end="getGoodsDetailFun"></u-count-down>
						</view>
					</view>
				</view>

				<view class="goods-info ">
					<image style="width: 726rpx; height: 94rpx; margin-left: -4rpx;"
						src="https://fx.senge.com/uploads/mini/sengeimg/xq.png" mode=""></image>
					<view class="info-header" v-if="goodsType != 1">
						<view class="price flex-s " style="color: #fff;width: 680rpx; padding: 0 14rpx;">
							<view class="flex" v-if="goodsDetail.goods_type >=1 && goodsDetail.prepay_price">
								<view style="font-size: 30rpx;margin-right: 16rpx;">定金 </view>
								<view style="margin-right: 20rpx;">
									<price-format :price="goodsDetail.prepay_price" :first-size="46" :second-size="30"
										:subscript-size="30" :weight="500" color="#fff" />
								</view>
							</view>
							<view class=" m-r-10 md">
								<text style="margin-right: 10rpx;font-size: 24rpx;">全国统一零售价</text>
								<price-format :first-size="34" :second-size="32" :subscript-size="30"
									:price="goodsDetail.min_price" :weight="500"></price-format>
							</view>
						</view>
					</view>
					<view class="flex bg-white" style="width: 100%; margin-top: -16rpx;">
						<view class="name md bold">{{ goodsDetail.name }}</view>
						<image class="icon-share" src="/bundle/image/icon_share.png" @tap="showShareBtn = true"
							v-if="goodsType == 1"></image>
					</view>
					<view class="flex row-between xs lighter bg-white"
						style="padding: 0 0 10rpx  18rpx; border-radius: 0 0 16rpx 16rpx;">
						<view>
							<text v-if="goodsDetail.is_show_stock">库存:
								{{ checkedGoods.stock || goodsDetail.stock }}</text>
						</view>
						<image class="icon-share" src="/bundle/static/image/icon_share.png" @tap="showShareBtn = true">
						</image>
						<!-- <text>销量: {{ goodsDetail.sales_sum }}</text>
					<text>浏览量: {{ goodsDetail.clicks }}</text> -->
					</view>
				</view>

				<!-- 拼团的玩法说明 -->
				<view class="group-play bg-white mt20" v-if="goodsType == 2">
					<view class="title">拼团玩法</view>
					<view class="steps row">
						<view class="row step">
							<view class="number xxs">1</view>
							<view class="sm">开团/参团</view>
						</view>
						<view class="line"></view>
						<view class="row step">
							<view class="number xxs">2</view>
							<view class="sm">团满即成新团</view>
						</view>
						<view class="line"></view>
						<view class="row step">
							<view class="number xxs">3</view>
							<view class="sm">满员发货</view>
						</view>
					</view>
				</view>

				<view class="group-play bg-white mt20" v-if="teamFound.length">
					<!-- 已经发起拼团的列表 -->
					<view class="title">正在拼团中</view>
					<swiper v-if="teamFound.length" class="mt20 bg-white" autoplay="true" style="height: 240rpx;"
						vertical="true" circular="true" :interval="5000">
						<swiper-item v-for="(sitem, index) in teamFound" :key="index">
							<view class="group-list">
								<view v-for="(item, index2) in sitem" :key="index2"
									class="group-item bg-white row-between">
									<view class="row" style="max-width: 280rpx;">
										<u-image :src="item.avatar" width="80rpx" height="80rpx" border-radius="50%">
										</u-image>
										<view class="ml20 line1 normal">{{ item.nickname }}</view>
									</view>
									<view class="row ml20" style="flex: none;">
										<view class="column-center">
											<text class="sm normal">
												还差
												<text class="primary">{{ item.people - item.join }}</text>
												人成团
											</text>
											<view class="muted xs">
												剩余
												<u-count-down :timestamp="getTeamCountTime(item.invalid_time)"
													separator-color="#999" color="#999" :separator-size="24"
													:font-size="24" bg-color="transparent"
													@end="getGoodsDetailFun"></u-count-down>
											</view>
										</view>
										<view class="group-btn br60 white row-center" @tap="showSpecFun(3, item.id)">去参团
										</view>
									</view>
								</view>
							</view>
						</swiper-item>
					</swiper>
				</view>
				<view>
					<get-coupon :wrap-style="{'margin-top': '20rpx'}" :goods-id="goodsDetail.id"></get-coupon>
				</view>
				<view v-if="goodsDetail.shop_flow" class="bg-white flex-s bor-ra" style="padding: 30rpx;font-size: 24rpx;margin-bottom: 20rpx;">
					<view class="flex-s lc_box" v-for="(item,index) in goodsDetail.shop_flow">
						<view class="lc_bg">{{index+1}}</view>
						<view class="lc_name">{{item}}</view>
						<view class="lc_line">----</view>
					</view>
				</view>
				<view v-if="!goodsType" style="border-radius:16rpx 16rpx 0 0;" class="spec  bg-white " @tap="showSpecFun(0)">
					<view class="flex">
						<view class="text muted">选择</view>
						<view v-if="indeximg<=7" v-for="(item,indeximg) in goodsDetail.goods_item">
							<image class="xz_img" :src="item.image" mode=""></image>
						</view>
						<view class="xz_num">共{{goodsDetail.goods_item.length}}款</view>
					</view>
					<view class="flex" style="margin:10rpx 0 0 90rpx;">
						<view class="line-1 m-r-20 flex-1">已选：{{ checkedGoods.spec_value_str || '默认' }}</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="spec  bg-white" v-if="goodsDetail.arguments_text!=''">
					<view class="flex" style="align-items: flex-start;">
						<view class="text muted">参数</view>
						<view class="cs_row"v-for="(item,index) in goodsDetail.arguments_text" >
							<view class="cs_text ellipsis">{{item}}</view>
							<view class="cs_tit">{{index}}</view>
						</view>
					</view>
				</view>
				<view class="add_cen">
					<navigator hover-class="none" url="/pages/mine/user_add?type=2">
						<view class="address bg-white spec">
							<view class="flex">
								<view class="text muted">配送</view>
								<!-- <image class="icon-md m-r-20" src="../../static/image/icon_address.png"></image> -->
								<view class="flex-1 m-r-20 flex-start">
									<image style="width: 24rpx; height: 24rpx; margin-right: 6rpx;"
										src="../../static/image/dwb.png" mode=""></image>
									<view class="black md" style="color: #757575;" v-if="!address.contact">
										选择收货地址</view>
									<view v-else>
										<!-- 								<text class="name md m-r-10">{{address.contact}}</text>
									<text class="phone md">{{address.telephone}}</text> -->
										<view class="line-1 m-r-20 flex-1 ellipsis" style="width: 496rpx; color: #757575;">
											{{address.province}} {{address.city}} {{address.district}}
											{{address.address}}
										</view>
									</view>
								</view>
								<u-icon name="arrow-right"></u-icon>
							</view>
							<view class="flex-start"style="margin: 10rpx 0 0 84rpx;">
								<view class="lzsg">厂商配送</view>
								<view style="color: #f82b1a;font-size: 24rpx;">
									{{goodsDetail.shop_text}}</view>
							</view>
						</view>
					</navigator>
				</view>
				<view class="spec  bg-white " style="border-radius: 0 0 16rpx 16rpx;">
					<view class="flex">
						<view class="text muted">活动</view>
						<view class="flex" style="width: 590rpx;">
							<view class="line-1 m-r-20 flex-start flex-1">
								<view class="lzsg">礼在森歌</view>
								<view class="lzsg">优惠立减</view>
							</view>
							<!-- <u-icon name="arrow-right"></u-icon> -->
						</view>
					</view>
				</view>
				<view v-if="shoptype!=1" class="bor-ra bg-white m-t-20" style="padding: 16rpx 24rpx;">
					<view class="flex-s" @click="apifun.navigate('/bundle_b/pages/moreshop?name='+goodsDetail.shop_info.name+'&&list='+encodeURIComponent(JSON.stringify(shop_address_list)))">
						<view class="xx_title">线下体验门店</view>
						<view class="xx_all">共 {{shop_address_list.length}} 家门店 <u-icon name="arrow-right"
								style="font-size: 22rpx;margin-left: 6rpx;"></u-icon></view>
					</view>
					<view class="flex-s" v-if="index==0" v-for="(item,index) in shop_address_list">
						<view class="">
							<view v-if="goodsDetail.shop_info" class="xx_name">{{goodsDetail.shop_info.name}}</view>
							<view class="xx_address">地址：{{item.all_name||''}}</view>
						</view>
						<view class="ljck" @click="apifun.navigate('/bundle_b/pages/iddetail?shop_address_id='+item.id)">立即查看</view>
					</view>
				</view>
				<view class="evaluation bg-white m-t-20 bor-ra" style="padding-bottom: 20rpx;" id="evaluation">
					<router-link :to="{path: '/bundle/pages/goodsDetail/all_comments', query: {id: goodsDetail.id}}">
						<view class="title flex row-between">
							<view>
								<text class="balck m-r-10 "style="font-size: 24rpx">
									<text class="bold md" >评价</text>({{comment.all_comment}})</text>
							</view>
							<text class="xs" style="color: #757575;">好评率{{ comment.percent || '0%' }}
							<u-icon name="arrow-right"></u-icon></text>
						
							<!-- <view class="flex">
								<text class="lighter">查看全部</text>
							</view> -->
						</view>
					</router-link>
					<view class="flex-s">
						<view class="con" v-if="comment.one && comment.one.nickname">
							<view class="user-info flex">
								<image class="avatar m-r-20" :src="comment.one.avatar"></image>
								<view>
									<view class="user-name xs m-r-10">{{ comment.one.nickname }}</view>
									<u-rate style="font-size: 20rpx;" disabled size="26rpx" :color="colorConfig.primary" v-model="comment.one.goods_comment">
									</u-rate>
								</view>
							</view>
				<!-- 			<view class="muted xs m-t-10">
								<text class="m-r-20">{{ comment.one.create_time }}</text>
							</view> -->
							<view v-if="comment.one.comment" class=" xs dec m-t-10">{{ comment.one.comment }}</view>
						</view>
						<view class="con flex row-center muted" v-else>暂无评价</view>
						<view v-if="comment.one && comment.one.nickname" class="" style="width: 136rpx;height: 136rpx;margin-right: 30rpx;">
							<image style="width: 136rpx;height: 136rpx;" v-if="index==0"
							 :src="item" mode="" v-for="(item,index) in comment.one.image"></image>
						</view>
					</view>
				</view>
				<view class="goods-shop m-t-20 bg-white" v-if="appConfig.shop_hide_goods == 1">
					<goods-shop :shop="shop"></goods-shop>
				</view>
				<view class="details m-t-20 bg-white bor-ra" id="details">
					<view class="flex-start">	
						<image style="width: 8rpx;height: 40rpx;margin:  0 14rpx 0 22rpx;" src="../../static/image/gg.png" mode=""></image>
						<view class="title md bold">详情</view>
					</view>
					<view v-if="goodsDetail.cs_content" class="twotitle flex-start">
						<image class="xq1" src="../../static/image/xq1.png" mode=""></image>
						<view class="sm bold">规格参数</view>
					</view>
					<view v-if="goodsDetail.cs_content" class="content">
						<u-parse :html="goodsDetail.cs_content" :lazy-load="true" :show-with-animation="true"></u-parse>
					</view>
					<view v-if="goodsDetail.hd_image&&goodsDetail.qy_image" class="twotitle flex-start">
						<image class="xq1" src="../../static/image/xq2.png" mode=""></image>
						<view class="sm bold" style="margin: 20rpx 0;">活动专区</view>
					</view>
					<view v-if="goodsDetail.hd_image" class="content">
						<button open-type="contact" hover-class="btn-hover">
						<image style="width: 100%; height: 160rpx;" :src="goodsDetail.hd_image" mode=""></image>
						</button>
					</view>
					<view v-if="goodsDetail.qy_image" class="content">
						<image style="width: 100%; height: 380rpx;" :src="goodsDetail.qy_image" mode=""></image>
					</view>
					<view v-if="goodsDetail.content" class="twotitle flex-start">
						<image class="xq1" src="../../static/image/xq3.png" mode=""></image>
						<view class="sm bold" style="margin: 20rpx 0;">商品介绍</view>
					</view>
					<view v-if="goodsDetail.content" class="content">
						<u-parse :html="goodsDetail.content" :lazy-load="true" :show-with-animation="true"></u-parse>
					</view>
				</view>
			</view>
			<!-- 意向弹框 -->
			<uni-popup ref="popup" type="center">
				<view class="popupBox">
					<view class="popuprow flex-start">
						<view class="popupname">姓名：</view>
						<input type="text" placeholder="请输入姓名" v-model="popname">
					</view>
					<view class="popuprow flex-start">
						<view class="popupname">电话：</view>
						<input type="text" placeholder="请输入电话" v-model="popphone">
					</view>
					<view @click="showRegion = true">
						<u-field v-model="region" :disabled="true" label="所在地区" placeholder="请选择省、市、区"
							right-icon="arrow-right">
						</u-field>
					</view>
					<view>
						<u-field v-model="xqaddress" type="textarea" label="详细地址" placeholder="请填写小区、街道、门牌号等信息"
							:field-style="{flex: 1, height: '200rpx'}" />
					</view>
					<view class="submit-s mainbgColor" @click="yixiang()">提交意向</view>
				</view>
				<u-select v-model="showRegion" mode="mutil-column-auto" @confirm="regionChange"
					:list="lists"></u-select>
			</uni-popup>
			<view class="footer flex bg-white fixed">
				<!-- <router-link :to="{ 
					path: '/bundle/pages/chat/chat',
					query: {
						shop_id: shop.id,
						goods_id: id
					}}"> -->
				<view class="btn flex-col col-center row-center" @click="$refs.popup.open('center')">
					<image class="icon-md" src="../../static/image/yixiang.png"></image>
					<text class="xxs lighter">意向</text>
				</view>
				<!-- </router-link> -->
				<!-- <router-link :to="{
					path: '/bundle/pages/chat/chat',
					query: {
						shop_id: shop.id,
						goods_id: id
					}}">
					<view class="btn flex-col col-center row-center">
						<image class="icon-md" src="/bundle/static/image/detailKefu.png"></image>
						<text class="xxs lighter">意向</text>
					</view>
				</router-link> -->

				<!-- <button class="btn flex-col col-center row-center" hover-class="none" @tap="collectGoodsFun">
					<image class="icon-md"
						:src="goodsDetail.is_collect == 1 ? '/bundle/static/image/detailCollect_s.png' : '/bundle/static/image/detailCollect.png'">
					</image>
					<text class="xxs lighter">收藏</text>
				</button> -->
				<router-link nav-type="pushTab" to="/pages/car/index">
					<view class="flex-col btn cart col-center row-center">
						<image class="icon-md" src="/bundle/static/image/detailCar.png"></image>
						<text class="xxs lighter">购物车</text>
						<u-badge v-if="cartNum" :bgColor="colorConfig.primary" :offset="[8, 10]" :count="cartNum">
						</u-badge>
					</view>
				</router-link>
				<template v-if="shop.is_pay">
					<!-- goodsDetail.type == 0 是虚拟商品时购物车不显示 -->
					<view v-if="btnText.yellow && goodsDetail.type == 0" class="add-cart br60 white m-r-10 md m-l-20"
						@tap="showSpecFun(1)">
						{{ btnText.yellow }}
					</view>
					<view class="right-buy br60 white m-r-20 m-l-10 md" @tap="showSpecFun(2)">{{ btnText.red }}</view>
				</template>
				<view v-else class="consult-btn br60 white m-r-20 md m-l-20" @tap="handleConsult">
					咨询商家
				</view>

			</view>
		</view>
		<view v-else>
			<view class="details-null flex-col col-center">
				<image class="img-null" src="/bundle/static/image/goods_null.png"></image>
				<view class="xs muted">该商品已下架或不存在，去逛逛别的吧~</view>
			</view>
			<goods-column></goods-column>
		</view>
		<!-- 规格 -->
		<spec-popup :shop_id="goodsDetail.shop_id" :show="showSpec" :is-seckill="goodsType == 1" :goods="goodsDetail"
			@close="showSpec = false" :show-add="popupType == 1 || popupType == 0"
			:show-buy="popupType == 2 || popupType == 0" :show-stock="goodsDetail.is_show_stock == 1"
			:show-confirm="popupType == 3" @buynow="onBuy" :type="goodsDetail.type" :group="!!isGroup"
			@addcart="onAddCart" @change="onChangeGoods" :red-btn-text="btnText.red" :yellow-btn-text="btnText.yellow"
			@confirm="onConfirm"></spec-popup>
		<!-- 分享海报 -->
		<share-popup v-model="showShareBtn" :share-id="id" pagePath="bundle/pages/goodsDetail/index" type="1" :config="{
        	avatar: userInfo.avatar,
        	nickname: userInfo.nickname,
        	image: goodsDetail.poster || goodsDetail.image,
        	price: goodsDetail.min_price,
        	marketPrice: goodsDetail.market_price,
        	name: team.share_title || goodsDetail.name
          }" />

		<share-popup :show="showShareBtn" @close="showShareBtn = false" :goods-id="id" :img-url="goodsDetail.image"
			:summary="goodsDetail.remark" :share-title="goodsDetail.name"></share-popup>
		<!-- 悬浮按钮 -->
		<!-- <float-tab></float-tab> -->
		<!-- 佣金显示 -->
		<view class="share-money" :class="{ show: showCommission && enableCommission}">
			<view class="row-end">
				<view class="share-close row-center" @tap="showCommission=false">
					<u-icon name="close" size="16" color="#fff"></u-icon>
				</view>
			</view>
			<view class="share-con mt10" @tap="showShareBtn=true">
				<view class="primary" style="font-size: 45rpx;">
					{{distribution.earnings}}<text class="xs">元</text>
				</view>
				<view class="lighter xxs">
					好友下单最高可赚
				</view>
			</view>
		</view>
		<loading-view v-if="isFirstLoading"></loading-view>
		<view class="indexIconBox">
			<view><button open-type="contact" hover-class="btn-hover">
					<image class="indexIcon" src="../../../static/image/indexIcon1.png" mode=""></image>
				</button></view>
			<view v-if="userInfo.level!==4">
				<router-link class="" :to="{path: '/pages/mine/invite_fans'}">
					<image class="indexIcon" src="../../../static/image/indexIcon2.png" mode=""></image>
				</router-link>
			</view>
		</view>
	</view>
</template>
<!-- team_min_price -->
<script>
	import {
		getaddress
	} from '@/api/order';
	import {
		VerApply,
	} from '@/api/user';
	import area from '@/utils/area'
	import {
		getGoodsDetail,
		addCart,
		footprintUpLength,
		SenGoodsNotice,
	} from '@/api/store';
	import {
		collectGoods
	} from '@/api/user';
	import {
		getCouponList,
		teamCheck
	} from '@/api/activity';
	import {
		mapActions,
		mapGetters
	} from 'vuex';
	import {
		toLogin
	} from '@/utils/login';
	import Cache from '@/utils/cache';
	import {
		strToParams,
		arraySlice,
		getRect,
		getcu
	} from '@/utils/tools'
	const app = getApp()
	export default {
		data() {
			return {
				active: 0,
				region: '',
				xqaddress: '',
				showRegion: false,
				isTouchStart: false,
				topArr: [],
				isFirstLoading: true,
				isNull: false,
				isGroup: 0,
				showSpec: false,
				showCoupon: false,
				showShareBtn: false,
				showCommission: true,
				popupType: '',
				popaddress: '',
				popname: '',
				popphone: '',
				shoptype: '',
				swiperList: [],
				shop_address_list: [{}],
				goodsDetail: {
					goods_item: '',
				},
				goodsType: 0,
				checkedGoods: {},
				comment: {},
				countTime: 0,
				team: {},
				teamFound: [],
				navStyle: {
					backBg: 0.4,
					backgroundBg: 0,
					backColor: 'rgba(256,256,256,1)'
				},
				id: '',
				shop: {},
				// 分销
				distribution: {},
				lists: [],
				shop_id: '',
				addressId: '',
				address: {},
			};
		},
		onLoad() {
			this.VerApply();
			this.$nextTick(() => {
				this.lists = area
			})
			const options = this.$Route.query;
			if (options && options.scene) {
				const scene = strToParams(decodeURIComponent(options.scene));
				options.id = scene.id;
			}
			this.id = options.id;
			this.getCartNum();
			uni.$on("selectaddress", (e) => { //切换之后地址id的参数
				this.addressId = e.id;
				this.taddress()
			})
			this.taddress()
		},
		onShow() {

		},
		onHide() {
			this.footprintUpLength()
		},
		onUnload() {
			this.footprintUpLength()
		},
		onPageScroll(e) {
			const top = uni.upx2px(500)
			const {
				scrollTop
			} = e
			const percent = scrollTop / top
			this.navStyle.backgroundBg = percent
			this.navStyle.backBg = 0.4 * (0.5 - percent)
			this.navStyle.backColor = percent < 0.5 ? 'rgba(256,256,256,' + (0.5 - percent) * 2 + ')' : 'rgba(0,0,0,' +
				(
					percent - 0.5) * 2 + ')'
			if (!this.isTouchStart) return
			const topList = this.topArr.map((item, index) => ({
					index,
					top: item
				}))
				.filter(item => item.top <= scrollTop)

			if (topList.length) {
				const index = topList.sort((a, b) => b.top - a.top)[0].index
				if (this.active == index) return
				this.active = index
			}
		},
		methods: {
			...mapActions(['getCartNum', 'wxShare']),

			taddress() {
				getaddress({
					address_id: uni.getStorageSync('selectaddress_id')
				}).then(({
					data
				}) => {
					this.address = data
					console.log('youwu', this.address)
					this.getGoodsDetailFun()
				})
			},
			regionChange(region) {
				this.province_id = region[0].value;
				this.city_id = region[1].value;
				this.district_id = region[2].value;
				this.region = region[0].label + " " + region[1].label + " " + region[2].label
			},
			async VerApply() {
				const {
					code,
					data
				} = await VerApply()
				// console.log('data',data);
				if (code == 1) {
					this.condition = data
				}
			},
			changeActive(index) {
				this.isTouchStart = false
				uni.pageScrollTo({
					scrollTop: this.topArr[index],
					duration: 200
				});
			},
			getRectInfo() {
				if (this.topArr.length) return
				getRect('#goods').then((res) => {
					this.topArr[0] = res.top - this.navHeight
				})
				getRect('#evaluation').then((res) => {
					this.topArr[1] = res.top - this.navHeight
				})
				getRect('#details').then((res) => {
					this.topArr[2] = res.top - this.navHeight
				})
			},
			async yixiang() {
				if (this.apifun.testphone.test(this.popphone) == false) {
					this.apifun.toast("手机格式有误");
					return false
				};
				const {
					data,
					code,
					msg
				} = await SenGoodsNotice({
					goods_id: this.goodsDetail.id,
					real_name: this.popname,
					address: this.xqaddress,
					mobile: this.popphone,
					province_id: this.province_id,
					city_id: this.city_id,
					district_id: this.district_id
				});
				if (code == 1) {
					this.$refs.popup.close()
					this.$toast({
						title: msg
					});
					this.popname = ''
					this.address = ''
					this.popphone = ''
					this.province_id = ''
					this.city_id = ''
					this.district_id = ''
				}
			},
			async footprintUpLength() {
				const {
					data,
					code
				} = await footprintUpLength({
					id: this.goodsDetail.footprint_id
				});
				if (code == 1) {

				}
			},
			async getGoodsDetailFun() {
				const {
					data,
					code
				} = await getGoodsDetail({
					goods_id: this.id,
					address_id: uni.getStorageSync('selectaddress_id') || this.address.id,
					shop_id: uni.getStorageSync('nearby_shops')
				});
				if (code == 1) {
					const {
						goods_image,
						content,
						comment,
						like,
						activity,
						shop,
						distribution
					} = data;
					let {
						info,
						type,
						team,
						found,
						end_time
					} = activity; //秒杀时间
					console.log(activity)
					//拼团的结束时间-现在的时间 = 剩余的时间
					let time = end_time ? end_time - Date.now() / 1000 : info ? info.activity_end_time -
						Date.now() / 1000 : 0;

					if (found) {
						found = arraySlice(found, [], 2);
					}
					this.distribution = distribution || {}
					this.shop = shop
					this.goodsDetail = data;
					this.shop_address_list = data.shop_info.shop_address_list;
					this.shoptype = data.shop.type;
					this.swiperList = goods_image;
					this.comment = comment || {};
					this.countTime = time;
					this.goodsType = type;
					this.team = info ? info : {};
					this.teamFound = found ? found : [];

					this.$nextTick(() => {
						// 滚动到顶部，防止h5端出现问题
						uni.pageScrollTo({
							scrollTop: 0,
							duration: 0,
						});
						this.isFirstLoading = false;
						this.getRectInfo()
					});
					// #ifdef H5
					const options = {
						shareTitle: this.team.share_title || data.name,
						shareImage: data.image,
						shareDesc: this.team.share_intro || data.remark
					};
					this.wxShare(options);
					// #endif
				} else {
					this.isNull = true
					this.isFirstLoading = false;
				}
			},

			async collectGoodsFun() {
				if (!this.isLogin) return this.$Router.push('/pages/login/login')
				const {
					goodsDetail: {
						is_collect
					}
				} = this;
				const {
					msg,
					code
				} = await collectGoods({
					goods_id: this.id
				});
				if (code == 1) {
					{
						this.$toast({
							title: msg
						});
					}
					this.getGoodsDetailFun();
				}
			},
			showCouponFun() {
				if (!this.isLogin) return toLogin();
				this.showCoupon = true;
			},
			onChangeGoods(e) {
				this.checkedGoods = e.detail;
			},
			showSpecFun(type, id) {
				if (!this.address.contact) {
					this.apifun.toast('请选择收货地址')
					// console.log(101)
				} else {
					if (this.goodsType == 2 && [2, 3].includes(type)) {
						this.isGroup = 1;
						this.foundId = id;
					} else {
						this.isGroup = 0;
						this.foundId = '';
					}
					this.popupType = type;
					this.showSpec = true;
				}
			},
			onBuy(e) {
				if (!this.isLogin) return this.$Router.push('/pages/login/login')
				const {
					id,
					goodsNum
				} = e.detail;
				const params = {
					goods: [{
						item_id: id,
						num: goodsNum,
						goods_id: this.id,
						shop_id: this.shop.id,
						delivery_type: this.goodsDetail.type
					}],
					type: 'buy'
				};
				this.showSpec = false
				this.goodsType == 2 ? (params.teamId = this.team.id) : '';
				this.foundId ? (params.foundId = this.foundId) : '';
				this.$Router.push({
					path: '/bundle/pages/confirm_order/confirm_order?id=' + this.shop.id,
					query: {
						data: params
					}
				})
			},

			onConfirm(e) {
				const {
					team: {
						team_id
					}
				} = this;

				teamCheck({
					team_id: this.foundId,
					// found_id: this.foundId,
					goods_id: e.detail.goods_id,
					item_id: e.detail.id,
					count: e.detail.goodsNum
				}).then(res => {
					if (res.code == 1) {
						this.onBuy(e);
					}
				});
			},

			async onAddCart(e) {
				if (!this.isLogin) return this.$Router.push('/pages/login/login')
				if (this.goodsType == 2) {
					// 拼团单独购买
					console.log('拼团单独购买')
					const params = {
						goods: [{
							item_id: e.detail.id,
							num: e.detail.goodsNum,
							delivery_type: this.goodsDetail.type,
							goods_id: this.id,
							shop_id: this.shop.id
						}],
						type: 'buy'
					};
					this.$Router.push({
						path: '/bundle/pages/confirm_order/confirm_order',
						query: {
							data: params
						}
					})
					return
				}

				const {
					id,
					goodsNum
				} = e.detail;
				const {
					code,
					data,
					msg
				} = await addCart({
						item_id: id,
						goods_num: goodsNum,
						// shop_id: this.goodsDetail.shop_id
					},
					// console.log('shop_id1',this.goodsDetail.shop_id)
				);
				if (code == 1) {
					this.getCartNum();
					this.$toast({
						title: msg,
						icon: 'success'
					});
					this.showSpec = false;
					// console.log('shop_id3',this.goodsDetail.shop_id)
					uni.setStorageSync("nearby_shops", this.goodsDetail.shop_id)
				}
			},
			handleConsult() {

				uni.makePhoneCall({
					phoneNumber: this.shop.mobile.toString() //仅为示例
				});
			}
		},
		async onShareAppMessage() {
			const {
				goodsDetail,
				inviteCode,
				team
			} = this;
			return {
				title: team.share_title || goodsDetail.name,
				imageUrl: goodsDetail.image,
				path: '/bundle/pages/goodsDetail/index?id=' + this.id 
			};
		},
		computed: {
			...mapGetters(['cartNum', 'inviteCode', 'sysInfo', 'appConfig', 'userInfo']),
			btnText() {
				const {
					goodsType
				} = this;
				switch (goodsType) {
					case 1:
						return {
							red: '立即抢购',
								yellow: ''
						};
					case 2:
						return {
							red: '立即开团',
								yellow: '单独购买'
						};
					default:
						return {
							red: '立即购买',
								yellow: '加入购物车'
						};
				}
			},
			getTeamCountTime() {
				return time => time - Date.now() / 1000;
			},
			navHeight() {
				return this.sysInfo.navHeight
			},
			enableCommission() {
				const {
					goodsType,
					distribution: {
						earnings,
						is_show
					}
				} = this
				return goodsType == 0 && earnings > 0 && is_show == 1
			}
		}
	};
</script>

<style lang="scss" scoped>
	@import '@/styles/base.scss';

	page {
		background-color: #f2f2f2;
	}
	.twotitle{
		margin: -10rpx 0 16rpx 24rpx;
	}
	.xq1{
		width: 38rpx;
		height: 38rpx;
		margin-right: 8rpx;
	}
	.xx_title{
		font-weight: bold;
		font-size: 28rpx;
	}
	.xx_all{
		font-size: 24rpx;
		color: #a0a0a0;
	}
	.xx_name{
		font-size: 26rpx;
		margin: 22rpx 0 8rpx 0;
	}
	.ljck{
		border: 1rpx solid #909090;
		border-radius: 30rpx;
		padding: 2rpx 14rpx;
		font-size: 24rpx;
	}
	.xx_address{
		font-size: 22rpx;
		color: #a0a0a0;
	}
	.lc_box:last-child .lc_line{
		display: none;
	}
	.lc_box:first-child .lc_bg{
		background-color: #fdf5ea;
		color: #ff9335;
	}
	.lc_box:first-child .lc_name{
		color: #ff9335;
	}
	.lc_name{
		padding: 0 8rpx;
	}
	.lc_bg{
		background-color: #eaeaea;
		padding: 2rpx 8rpx;
	}
	
	.cs_row {
		width: 200rpx;
		border-right: solid 1rpx #dddcdc;
		text-align: center;
		padding: 0 2rpx;
	}
	.cs_tit{
		color: #ababab;
	}

	.cs_row:last-child {
		border-right: none;
	}

	.lzsg {
		font-size: 22rpx;
		padding: 0 6rpx;
		color: #f82b1a;
		border: 1rpx solid #f82b1a;
		margin-right: 14rpx;
	}

	.xz_num {
		padding: 10rpx 16rpx;
		background-color: #f9f9f9;
		font-size: 26rpx;
	}

	.xz_img {
		width: 50rpx;
		height: 50rpx;
		margin-right: 6rpx;
	}

	.border-ra16 {
		border-radius: 16rpx;
	}

	.goods-details {
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));

		.seckill {
			height: 100rpx;
			background: #ffd4d8;

			.price {
				width: 504rpx;
				height: 100%;
				background: url(../../static/image/bg_seckill.png) no-repeat;
				background-size: 100%;
			}

			.down {
				flex: 1;
			}
		}

		.group {
			height: 100rpx;
			width: 100%;
			background-image: url(../../static/image/pintuan_bg.png);
			background-size: 100%;

			.group-num {
				border: 1px solid #ffffff;
				border-radius: 4rpx;

				.group-icon {
					background: #fff;
					padding: 3rpx 7rpx;
				}
			}

			.down {
				height: 100%;
				background-color: #fff5e1;
				padding: 0 20rpx;
			}
		}

		.goods-info {
			margin-top: 20rpx;
			position: relative;

			.info-header {
				padding: 20rpx 0 0rpx 24rpx;
				position: absolute;
				top: 0rpx;

				// margin-top: -120rpx;
				.price {
					align-items: baseline;
				}
			}

			.name {
				padding: 20rpx 24rpx 0 20rpx;
				flex: 1;
			}

			.icon-share {
				width: 114rpx;
				height: 50rpx;
			}

			.vip-price {
				margin: 0 24rpx;
				background-color: #FFE9BA;
				line-height: 36rpx;
				border-radius: 6rpx;
				overflow: hidden;

				.price-name {
					background-color: #101010;
					padding: 8rpx 18rpx;
					color: #FFD4B7;
					position: relative;
					overflow: hidden;

					&::after {
						content: '';
						display: block;
						width: 20rpx;
						height: 20rpx;
						position: absolute;
						right: -15rpx;
						background-color: #FFE9BA;
						border-radius: 50%;
						top: 50%;
						transform: translateY(-50%);
						box-sizing: border-box;
					}
				}
			}
		}



		.details-null {
			padding-top: 140rpx;
			margin-bottom: 100rpx;
		}

		.spec {
			padding: 24rpx 24rpx;

			.text {
				width: 80rpx;
			}
		}

		.evaluation {
			.title {
				height: 80rpx;
				// border-bottom: $-solid-border;
				padding: 0 24rpx;
			}

			.con {
				padding: 0rpx 24rpx;
			}

			.user-info .avatar {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
			}
		}

		.details {

			// overflow: hidden;
			.title {
				line-height: 88rpx;
				// text-align: center;
			}

			&>.content {
				padding: 0 20rpx 20rpx;

				::v-deep image {
					vertical-align: middle;
				}

				// #ifdef H5
				::v-deep img {
					vertical-align: middle;
				}

				// #endif
				// #ifdef MP-WEIXIN || APP-PLUS
				::v-deep ._img {
					display: block;
				}

				// #endif
			}
		}

		.footer {
			height: 100rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			box-sizing: content-box;
			padding-bottom: env(safe-area-inset-bottom);

			.btn {
				width: 100rpx;
				height: 100rpx;
				position: relative;
				line-height: 1.3;
			}

			.cart-num {
				position: absolute;
				left: 60rpx;
				top: 6rpx;
			}

			.add-cart,
			.right-buy,
			.consult-btn {
				flex: 1;
				text-align: center;
				padding: 16rpx 0;
			}

			.add-cart {
				background-color: #ffa630;
			}

			.right-buy {
				background-color: $-color-primary;
			}

			.consult-btn {
				background: linear-gradient(to right, #ff8e00 0%, #ff2c3c 100%);
			}
		}

		.group-play {
			.title {
				padding: 20rpx 28rpx;
				border-bottom: $-solid-border;
			}

			.steps {
				padding: 20rpx 28rpx;

				.step {
					flex: none;
				}

				.line {
					flex: 1;
					border: 1px dashed #999999;
					margin: 0 20rpx;
				}

				.number {
					border: 1rpx solid #707070;
					width: 28rpx;
					height: 28rpx;
					border-radius: 50%;
					line-height: 28rpx;
					text-align: center;
					margin-right: 6rpx;
				}
			}
		}

		.group-list {
			.group-item {
				padding: 20rpx 24rpx;

				&:not(:last-of-type) {
					border-bottom: $-solid-border;
				}

				.group-btn {
					background: linear-gradient(90deg, #f95f2f 0%, #ff2c3c 100%);
					height: 58rpx;
					padding-left: 28rpx;
					padding-right: 28rpx;
					margin-left: 30rpx;
					box-shadow: 0px 6rpx 12rpx rgba(249, 47, 138, 0.4);

				}
			}
		}

		.share-money {
			position: fixed;
			left: 20rpx;
			bottom: calc(130rpx + env(safe-area-inset-bottom));
			transform: scale(0);
			transition: all .3s;

			&.show {
				transform: scale(1);
			}

			.share-close {
				width: 34rpx;
				height: 34rpx;
				background: #a7a7a7;
				border-radius: 50%;
			}

			.share-con {
				background: url('../../static/image/bg_packet_img.png');
				width: 241rpx;
				height: 208rpx;
				background-size: 100%;
				padding-top: 20rpx;
				text-align: center;
			}
		}
	}

	.popupBox {
		width: 660rpx;
		background-color: #f5f5f5;
		border-radius: 18rpx;
		padding: 30rpx 0;
		font-size: 30rpx;
	}

	.popuprow {
		margin: 34rpx 24rpx;
	}

	.popuprow input {
		width: 500rpx;
		font-size: 30rpx;
		color: #808080;
		margin-left: 10rpx;
	}

	.submit-s {
		border-radius: 50rpx;
		padding: 12rpx;
		font-size: 32rpx;
		background-color: #f5335e;
		margin-bottom: 18rpx;
	}

	.indexIcon {
		width: 100rpx;
		height: 100rpx;
	}

	.indexIconBox {
		position: fixed;
		right: 20rpx;
		bottom: 160rpx;
	}
</style>